/* ************************************************************
	Site: skipslate
	File: main.js
	Description: Base script for skipslate.
	
	
	Copyright (c) 2007 Brice Mason
************************************************************ */

function init_app() {
	var article_tab = new YAHOO.widget.TabView( "ui_article", { orientation: "left" } );
	
	dp.SyntaxHighlighter.HighlightAll( "code" );
}

// ***********************************************************
function trim(str){
	str = str.replace(/^\s+/, "");
	str = str.replace(/\s+$/, "");
	return(str);
}
// ***********************************************************
function isEmail(ea){
	var bad_email = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(^\s+)/;
  	var good_email = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
  	if (!bad_email.test(ea) && good_email.test(ea)) {
		return true;
	}
	else{
		return false;
	}
}
// ***********************************************************

function check_comment( f ) {
	if( isBlank( f.name ) ){
		alert( "Please enter your name" );
		return false;
	}
	
	if( isBlank( f.email ) == false && isEmail( f.email.value ) == false ) {
		alert( "Please enter a correctly formatted e-mail address" );
		return false;
	}
	
	if( isBlank( f.comment ) ) {
		alert( "Please enter a comment" );
		return false;
	}
	
	return true;
}
function isBlank(objText){
	var strText = trim(objText.value);
		if(strText.length == 0){
			objText.value = strText;
			objText.focus();
			return true;
		}
		else{
			objText.value = strText;
			return false;
		}
}
// ***********************************************************
